using System;
using log4net;

namespace NFreeMarker.Log
{
    /**
     * @version $Id: Log4JLoggerFactory.java,v 1.8 2005/05/04 12:02:43 ddekany Exp $
     * @author Attila Szegedi
     */
    class Log4JLoggerFactory : ILoggerFactory
    {
        public Logger GetLogger(string category)
        {
            return new Log4JLogger(LogManager.GetLogger(category));
        }

        private class Log4JLogger : Logger
        {
            private readonly ILog _logger;

            internal Log4JLogger(ILog logger)
            {
                _logger = logger;
            }
            
            public override void Debug(string message)
            {
                _logger.Debug(message);
            }

            public override void Debug(string message, Exception e)
            {
                _logger.Debug(message, e);
            }

            public override void Error(string message)
            {
                _logger.Error(message);
            }

            public override void Error(string message, Exception e)
            {
                _logger.Error(message, e);
            }

            public override void Info(string message)
            {
                _logger.Info(message);
            }

            public override void Info(string message, Exception e)
            {
                _logger.Info(message, e);
            }

            public override void Warn(string message)
            {
                _logger.Warn(message);
            }

            public override void Warn(string message, Exception e)
            {
                _logger.Warn(message, e);
            }

            public override bool IsDebugEnabled()
            {
                return _logger.IsDebugEnabled;
            }

            public override bool IsInfoEnabled()
            {
                return _logger.IsInfoEnabled;
            }

            public override bool IsWarnEnabled()
            {
                return _logger.IsWarnEnabled;
            }

            public override bool IsErrorEnabled()
            {
                return _logger.IsErrorEnabled;
            }

            public override bool IsFatalEnabled()
            {
                return _logger.IsFatalEnabled;
            }
        }
    }
}